package com.thyme.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.thyme.system.vo.Iec61850IedInstVo;
import com.thyme.system.vo.IedNameEnumVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author nana
 * @since 2021-03-17
 */
public interface Iec61850IedInstDao extends BaseMapper<Iec61850IedInstVo> {

    /**
     *
     * @param iec61850IedInstVo
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert  into iec61850_ied_inst (ied_name,ied_desc,ied_ip,create_time,update_time) values (#{iedName},#{iedDesc},#{iedIp},now(),now())")
    void insertIec61850IedInst(Iec61850IedInstVo iec61850IedInstVo);

    @Select("select id from iec61850_ied_inst where ied_name = #{iedName}")
    Integer getByIEDName(@Param("iedName")String iedName);

    @Select("SELECT * FROM iec61850_ied_inst order by update_time desc")
    IPage<Iec61850IedInstVo> getAll(Page page);

    @Select("SELECT id,ied_name from iec61850_ied_inst order by update_time desc")
    List<IedNameEnumVO> getLEDNameEnumList();
}
